<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <title>员工管理</title>
    <link href="/res/css/respective/order/back-order.css" rel="stylesheet">
    <style type="text/css">
        .back-main a {
            text-decoration: none !important;
        }

        .blueBtn {
            display: inline-block;
            height: 32px;
            line-height: 32px;
            margin: 3px 0;
            text-align: center;
            color: #fff;
            background: #00b1db;
            border-radius: 3px;
            cursor: pointer;
            padding: 0 10px;
        }

        .grayBtn {
            display: inline-block;
            height: 32px;
            line-height: 32px;
            margin: 3px 0;
            text-align: center;
            color: #fff;
            background: gray;
            border-radius: 3px;
            cursor: pointer;
            padding: 0 10px;
        }
        
        .mainhead1{width: 100%;height: 40px;display: inline-block;}
		.mainhead_one{display: inline-block;height: 40px;float: left;width: 10%;text-align: center;line-height: 40px;font-weight: bold;color:#30D5F7;border-top: 2px solid #30D5F7;}
		.mainhead_two{display: inline-block;height: 40px;float: left;width: 10%;text-align: center;line-height: 40px;font-weight: bold;cursor: pointer;border-left: 1px solid #ddd;border-bottom: 1px solid #ddd;}
		.mainhead_three{display: inline-block;height: 40px;float: left;border-bottom: 1px solid #ddd;width:80%}
		.maincontext{display: inline-block;width: 100%;}
		.fchild{display: inline-block;float: right;}
		.fyjt{color:#b2b2b2;background-color: #FBFBFB;border:1px solid #ebebeb;padding: 0px 6px 0px 6px;margin: 21px 6px 0px 0px;cursor: pointer;}
		.warp .back-main .fyjt:hover {
			    color: #00ceff;
		}
		.warp.warp-supplier .back-main .fyjt:hover {
			    color: rgb(255, 192, 1);
		}
		.fygo{background-color: #09A8D2;color: #fff;padding: 1px 4px 1px 4px;margin: 22px 8px 0px 0px;cursor: pointer;}
		.fygo:hover{
			background-color: #00ceff;
		}
		.warp.warp-supplier .back-main .fygo{background-color: rgb(254, 169, 16);}
		.warp.warp-supplier .back-main .fygo:hover{
			background-color: rgb(255, 192, 1);
		}
		.fyin{margin-top: 21px;}
		.fyinput{border: 1px solid #ebebeb;
    height: 18px;
    width: 60px;}
		.fytext{font-size: 12px;margin: 21px 14px 0px 0px;}
		.addemp{display: inline-block;background-color:#00b1db;color: #fff;height: 32px;width: 95px;text-align: center;font-weight: bold;line-height: 32px;border-radius:2px; cursor: pointer;float: right;margin-top: 4px;}
		.addemp:hover{
			background-color: #00ceff;
		}
		.warp.warp-supplier .back-main .addemp{background-color:rgb(254, 169, 16);}
		.warp.warp-supplier .back-main .addemp:hover{
			background-color: rgb(255, 192, 1);
		}
		 tr{height:45px;}
		 td{word-wrap:break-word;}
		 .thht{border-top: none!important;}
		 .fenyediv{border-left: 1px solid #ddd;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;font-size: 12px;}
		 .mapic1{width: 21px;height: 21px;display: inline-block;float: left;background: url("/res/images/oparaStatus/modify_03.png") center no-repeat;}
		 .mapic2{width: 21px;height: 21px;display: inline-block;float: left;background-image: url("/res/images/oparaStatus/dapp.png");background-position: -43px -14px;}
		 .font1,.font2{float: left;}
		 .last_jj{width: 100px;display: inline-block;}
    </style>
</head>
[#assign menucode="employeesManage"/]
<body>
<div class="warp">
[#include "/front/common/front_headAzt.html"]
    <div class="backcontent">
    [#include "/front/common/front_leftAzt.html"]
        <div class="back-main">
            <div class="inner cotentIner">
                <div class="title" id="bedoreEmp">员工管理</div>
                <div class="maincontext">
	                <div class="backTab" style="margin-bottom: 0px;">
	                    <ul style="display: inline-block;">
	                        <li class="on">员工列表</li>
	                        <li onclick="location.href='/employee/employeeApply_list'">员工审核
	                        	[#if applyCount!=0]<span class="orange"><i></i>${applyCount!}</span>[/#if]
	                        </li>
	                    </ul>
	                    <div id="doaddUser" class="addemp">增加员工</div>
	                </div>
	             	<table class="table" style="text-align: center;border-left: 1px solid #ddd;border-right: 1px solid #ddd;table-layout: fixed;">
			 			<thead style="background-color: #f8f8f8;">
						   	<tr> 
								<th class="thht" width="18%">用户名</th>
								<th class="thht" width="20%">联系电话</th>
								<th class="thht" width="20%">员工姓名</th>
								<th class="thht" width="20%">所属角色</th>
								<th class="thht" width="22%">操作</th>
							</tr>
						</thead>
						<tbody>
							<!--默认显示8行-->
							[#list pagination.list as user]
							<tr>
								<td>
									[#if user.email??]
										${user.email}
									[#else]
										[#if user.mobile??]
											${user.mobile}
										[/#if]
									[/#if]
								</td>
								<td>${user.contactTel!}</td>
								<td>
								[#if user.realName??]
									${user.realName!}
								[#else]
									[#if user.email??]
										${user.email}
									[#else]
										[#if user.mobile??]
											${user.mobile}
										[/#if]
									[/#if]
								[/#if]
								</td>
								<td>${user.name}</td>
								<td class="blackLink" style="width: 250px;text-align: center;">
									[#if user.ifAdmin!=1]
									<div class="last_jj"> 
										<span class="mapic1"></span>
										<span class="font1"><a href="/employee/toemployee_edit?id=${user.id!}">修改</a></span>
										<span class="mapic2"></span>
										<span class="font2"><a style="cursor: pointer;" onclick="doDelEmp('${user.id!}')">删除</a></span>
									</div>
									[/#if]
								</td>
							</tr>
							[/#list]
						</tbody>
					</table>
					<div class="fenyediv" style="background: #F8F8F8;height: 60px;">
						 <div class="fchild fyjt" style="margin-right: 25px;" onclick="pageclick('empnext')">></div>
						 <div class="fchild fyjt" onclick="pageclick('emprev')"><</div>
						 <div class="fchild fygo" onclick="refempGO()">GO</div>
						 <div class="fchild fyin"><input class="fyinput"  type="text"></div>
						 <div class="fchild fytext" style="letter-spacing: 3px;"><span style="color: #FCB01C;">${pagination.pageNo!}</span>/${pagination.totalPage!}</div>
						 <div class="fchild fytext">共${pagination.totalCount!}条记录</div>
						 <input id="pageNo" type="hidden" value="${pagination.pageNo!}">
						 <input id="totalPage" type="hidden" value="${pagination.totalPage!}">
						 <input id="showType" type="hidden" value="1">
					</div>
				</div> 
            </div>
        </div>
    </div>

[#include "/front/common/front_footerAzt.html"]
</div>

<script type="text/javascript" src="/res/js/common/jquery.1.9.1.min.js"></script>
<script type="text/javascript" src="/res/js/structure/struture.js"></script>
<script type="text/javascript" src="/res/js/common/common.js"></script>
<script type="text/javascript" src="/res/third/laydate/laydate.js"></script>
<script type="text/javascript" src="/res/third/layer/layer.js"></script>
<script type="text/javascript" src="/res/js/common/tppl.js"></script>
<script type="text/javascript" src="/res/third/nice-validator/jquery.validator.min.js?local=zh-CN"></script>
<script type="text/javascript">
$(function(){
	$(".cotentIner").css('minHeight',$(window).height()-200);
});
function submitpage(pageNo,showType){
	 var layerIndex;
	 $.ajax({
          url: 'employee_page',
          data: {pageNo:pageNo,showType:showType},
          type: 'post',
		  beforeSend : function () {
			  layerIndex = layer.load(1, {
				  shade: [0.1,'#fff'] //0.1透明度的白色背景
				});
          },
          success: function (data) {
             	if(data!=null){
             		$(".maincontext").remove();
             		$("#bedoreEmp").after(data);
             	}
          },
			complete : function() {
				layer.close(layerIndex);
			},
			error:function(xx){
				console.log(xx)
			}
      });
}
function pageclick(pagetype){
	 var pagetotal=parseInt($("#totalPage").val());
	 var pageNo=parseInt($("#pageNo").val());
	 var showType=$("#showType").val();
	 if(pagetype=='empnext'){
		 if(pageNo!=pagetotal){
			 pageNo=pageNo+1;
			 submitpage(pageNo,showType);
		 }
	 }
	 if(pagetype=='emprev'){
		 if(pageNo!=1){
			 pageNo=pageNo-1;
			 submitpage(pageNo,showType);
		 }
	 }
}
function refempGO(){
	 var pagetotal=parseInt($("#totalPage").val());
	 var pageNo=parseInt($(".fyinput").val());
	 var showType=$("#showType").val();
	 if(pageNo>=1&&pageNo<=pagetotal){
		 submitpage(pageNo,showType);
	 }
}
function doDelEmp(uid){
	layer.confirm('确认删除该员工吗？', {
	    btn: ['删除','取消'], //按钮
	    shade: 0.3 //显示遮罩
	}, function(index){
		var layerIndex;
		$.ajax({
	        url : 'doDelEmp',
	        type : 'post',
	        data:{uid:uid},
	        dataType : 'json',
			beforeSend : function () {
				layerIndex = layer.load(1, {
					  shade: [0.1,'#fff'] //0.1透明度的白色背景
					});
	        },
	        success : function(data) {
	        	 if(data.success){
	            	 layer.alert("删除成功",function(){
	            		 location.href='/employee/employee_list';
	            	 });
	             }else{
	            	 layer.alert(data.msg);
	             }
	        },
			complete : function() {
				layer.close(layerIndex);
			}
	    })
	    layer.close(index);
	});
	 
}
var pid='[#if pid??]${pid}[/#if]';
$(document).ready(function(){
		 var layerIndex;
		 $("#doaddUser").click(function(){
			 if(pid==''){
				 location.href='toAddUserView'
			 }else{
				 $.ajax({
	                   url : 'queryRoleByCompanyId',
	                   type : 'post',
	                   dataType : 'json',
					   beforeSend : function () {
						   layerIndex = layer.load(1, {
								  shade: [0.1,'#fff'] //0.1透明度的白色背景
								});
	                   },
	                   success : function(data) {
	                       if(data.success){
	                       	location.href='toAddUserView';
	                       }else{
	                       	layer.open({
		          					  btn:0,
		          					  title: '修改事项',
		          					  content: "<div style='width:300px;height:120px;margin-top:30px;'>"
		          					  				+"<div style='padding-left:20px;padding-right:20px;text-align:center;'>"
		          					  					+"<span style='display:inline-block;float:left;'>"+data.msg+"</span>"
		          					  				    +"<span class='addemp' style='float:none;'  onclick='location.href="+'"/orgstruct/addrole"'+"'>去创建</span>"
		          					  				+"</div>"
		          					  		  +"</div>",
		          					  success: function(layero, index){
		          						  $(layero).find(".layui-layer-title").remove();
		          					  }
	         					});

	                       }
	                   },
						complete : function() {
							layer.close(layerIndex);
						}
	               })
			 }
		 });
	});
</script>
</body>
</html>